import 'package:flutter/material.dart';

class TestPage extends StatefulWidget {
  const TestPage({Key key}) : super(key: key);
  @override
  _TestPageState createState() => _TestPageState();
}

class _TestPageState extends State<TestPage> {
  ScrollController _controller;

  @override
  void initState() {
    super.initState();

    _controller = ScrollController();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: SizedBox(
        height: 100,
        child: ListView.builder(
          controller: _controller,
          padding: EdgeInsets.only(right: 200),
          scrollDirection: Axis.horizontal,
          itemBuilder: (_, index) {
            return SizedBox(
              width: 80,
              child: FlatButton(
                color: Colors.white,
                onPressed: () {
                  _controller.animateTo(index * 80.0,
                      duration: const Duration(milliseconds: 300),
                      curve: Curves.ease);
                },
                child: Text(
                  'TAB$index',
                  style: TextStyle(
                    color: Colors.black,
                  ),
                ),
              ),
            );
          },
        ),
      ),
    );
  }
}
